package csse3004.GD.PAdmin;

/**
 * @author Mamdouh Alharbi- s4194298
 */
import csse3004.GD.DA.PollAdminDA;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;

public class ChangePasswordController extends SimpleFormController {

    private PollAdminService pollAdminService = new PollAdminDA();

    public ModelAndView onSubmit(Object command) throws ServletException {
        ChangePassword changePassword = (ChangePassword) command;
        String oldPassword = changePassword.getOldPassword();
        String newPassword = changePassword.getNewPassword();
        if (oldPassword != null && newPassword != null) {
            logger.info("old password: " + oldPassword);
            logger.info("new password " + newPassword);
            String changed = "Password changed successfully";

            return new ModelAndView("home", "changed", changed);
        }
        return new ModelAndView("changePassword");
    }
}